﻿@model PagedList.IPagedList<TestOnlineProject.Models.Entities.DiscussionModel>
@using PagedList.Mvc;
<div id="list">
    <table class="table table-bordered">
        @if (Model.Count == 0)
        {
            <tr style="padding: 2px">
                <td style="padding-left: 20px">
                    <span>No result!</span>
                </td>
            </tr>
        }
        @foreach (var item in Model)
        {
            if (item.Discussion.IsActivated)
            {
                <tr style="padding: 2px">
                    <td style="padding-left: 20px">
                        @if (item.Discussion.ParentId != null)
                        {
                            <span>
                                <b>@Html.ActionLink(@item.Discussion.Title, "Details", "Discussion", new { discussionId = @item.Discussion.ParentId, thread = @item.Discussion.DiscussionId }, new { style = "color: #127BC0; font-size: 18px" })</b>
                            </span>
                        }
                        else
                        {
                            <span>
                                <b>@Html.ActionLink(@item.Discussion.Title, "Details", "Discussion", new { discussionId = @item.Discussion.DiscussionId }, new { style = "color: #127BC0; font-size: 18px" })</b>
                            </span>
                        }
                        <br />
                        @if (@item.TotalReplies == 0)
                        {
                            <span style="padding-right: 20px; font-size: 12px">
                                <i class="icon-user"></i> Started by @item.LastUser
                            </span>
                        }
                        else
                        {
                            <span style="padding-right: 20px; font-size: 12px">
                                <i class="icon-user"></i> Most recent by @item.LastUser
                            </span>
                        }
                        <span style="padding-right: 20px; font-size: 12px">
                            <i class="icon-calendar"></i> @item.LastPost
                        </span>
                    </td>
                    @if (ViewBag.MyDiscussion == "False")
                    {
                        <td>
                            <div style="padding: 2px; background-color: #EFEFEF; text-align: center">
                                <span>Comments</span>
                                <br />
                                <span style="font-size: 18px"><b>@item.TotalReplies</b></span>
                            </div>
                        </td>
                        <td style="width: 20%">
                            <span style="font-size: 12px">New discussion: @item.LastPost</span>
                            <br />
                            <span style="font-size: 12px">by @item.LastUser</span>
                            <span style="font-size: 12px">
                                <a href="@Url.Content("~/Discussion/Details")?discussionId=@item.Discussion.DiscussionId&thread=@item.LastDiscussion"><i class="icon-forward"></i></a>
                            </span>
                        </td>
                    }
                    @if (HttpContext.Current.User.IsInRole("1"))
                    {
                        <td class="span1" style="text-align: center">
                            <span>
                                <input type="checkbox" value="@item.Discussion.DiscussionId" class="is_selected"/>
                            </span>
                        </td>
                    }
                </tr>
            }
            else
            {
                <tr style="padding: 2px; background-color: #EEEEEE">
                    <td style="padding-left: 20px">
                        @if (item.Discussion.ParentId != null)
                        {
                            <span>
                                <b>@Html.ActionLink(@item.Discussion.Title, "Details", "Discussion", new { discussionId = @item.Discussion.ParentId, thread = @item.Discussion.DiscussionId }, new { style = "color: #127BC0; font-size: 18px" })</b>
                            </span>
                        }
                        else
                        {
                            <span>
                                <b>@Html.ActionLink(@item.Discussion.Title, "Details", "Discussion", new { discussionId = @item.Discussion.DiscussionId }, new { style = "color: #127BC0; font-size: 18px" })</b>
                            </span>
                        }
                        <br />
                        @if (@item.TotalReplies == 0)
                        {
                            <span style="padding-right: 20px; font-size: 12px">
                                <i class="icon-user"></i> Started by @item.LastUser
                            </span>
                        }
                        else
                        {
                            <span style="padding-right: 20px; font-size: 12px">
                                <i class="icon-user"></i> Most recent by @item.LastUser
                            </span>
                        }
                        <span style="padding-right: 20px; font-size: 12px">
                            <i class="icon-calendar"></i> @item.LastPost
                        </span>
                    </td>
                    @if (ViewBag.MyDiscussion == "False")
                    {
                        <td>
                            <div style="padding: 2px; background-color: #EFEFEF; text-align: center">
                                <span>Comments</span>
                                <br />
                                <span style="font-size: 18px"><b>@item.TotalReplies</b></span>
                            </div>
                        </td>
                        <td style="width: 20%">
                            <span style="font-size: 12px">New discussion: @item.LastPost</span>
                            <br />
                            <span style="font-size: 12px">by @item.LastUser</span>
                            <span style="font-size: 12px">
                                <a href="@Url.Content("~/Discussion/Details")?discussionId=@item.Discussion.DiscussionId&thread=@item.LastDiscussion"><i class="icon-forward"></i></a>
                            </span>
                        </td>
                    }
                    @if (HttpContext.Current.User.IsInRole("1"))
                    {
                        <td class="span1" style="text-align: center">
                            <span>
                                <input type="checkbox" value="@item.Discussion.DiscussionId" class="is_selected"/>
                            </span>
                        </td>
                    }
                </tr>
            }
        }
    </table>
    @Html.PagedListPager(Model, page => Url.Action("Index", new { subjectId = ViewBag.SubjectId, page }))
</div>